package com.huawei.appgallery.forum.message.activity;

import android.app.ActionBar;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.huawei.appgallery.forum.base.ui.ForumActivity;
import com.huawei.appgallery.forum.message.api.IBuoyMsgSwitchSettingActivityProtocol;
import com.huawei.appgallery.forum.message.api.IBuoyMsgSwitchSettingActivityResult;
import com.huawei.appgallery.forum.message.api.IMessageHomeProtocol;
import com.huawei.appgallery.forum.message.api.IMessageHomeResult;
import com.huawei.appgallery.forum.message.fragment.IMessageHomeFrgProtocol;
import com.huawei.appgallery.forum.message.fragment.MessageHomeFragment;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.hmf.annotation.ActivityDefine;
import java.lang.ref.WeakReference;
import o.azb;
import o.bqv;
import o.bqx;
import o.bsv;
import o.bvj.a;
import o.bvj.c;
import o.bvj.e;
import o.bvj.j;
import o.bvy;
import o.cbh;
import o.AccountBussinessListener;
import o.ccp;
import o.cdb;
import o.cgv;
import o.doo;
import o.eke;
import o.eoj;
import o.evx;
import o.fho;
import o.fiu;
import o.fiv;
import o.fjb;
import o.fjc;
import o.fjm;
import o.fjo;
import o.fjq;
import o.fjt;
import o.FragmentTransaction;

@ActivityDefine(alias = "message_home_activity", protocol = IMessageHomeProtocol.class, result = IMessageHomeResult.class)
public class MessageHomeActivity extends ForumActivity {
    private Fragment ʻॱ;
    private int ˋॱ = 0;
    private String ͺ;
    private fiv ॱˊ = fiv.ॱ(this);
    private String ॱˋ;
    private int ॱˎ;
    private String ᐝॱ;

    static class b implements AccountBussinessListener {
        private WeakReference<MessageHomeActivity> ˋ;

        public b(MessageHomeActivity messageHomeActivity) {
            this.ˋ = new WeakReference(messageHomeActivity);
        }

        public void onAccountBusinessResult(ccp o_ccp) {
            MessageHomeActivity messageHomeActivity = (MessageHomeActivity) this.ˋ.get();
            if (messageHomeActivity != null && 103 == o_ccp.ˎ) {
                messageHomeActivity.finish();
            }
        }
    }

    public void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        setContentView(e.ˊ);
        getWindow().getDecorView().setBackgroundColor(getResources().getColor(a.ᐝ));
        cgv.ˋ(this, a.ॱ, a.ᐝ);
        this.ॱˋ = getResources().getString(j.ˎˎ);
        if (ͺ()) {
            ॱˊ();
            ʼॱ();
            return;
        }
        finish();
    }

    private boolean ͺ() {
        if (doo.ˊ((Context) this)) {
            IMessageHomeProtocol iMessageHomeProtocol = (IMessageHomeProtocol) this.ॱˊ.ॱ();
            if (iMessageHomeProtocol == null) {
                bqx.ॱ("MessageHomeActivity", "----------MessageHomeProtocol == null");
                return false;
            }
            this.ˋॱ = iMessageHomeProtocol.getSourceType();
            this.ᐝॱ = iMessageHomeProtocol.getDomainId();
            if (this.ˋॱ == 0) {
                this.ͺ = "forum|user_message|,im_1";
            } else if (this.ˋॱ == 1) {
                this.ॱˋ = getResources().getString(j.ʻॱ);
                this.ͺ = "forum|user_message|,im_0";
            } else if (this.ˋॱ == 2) {
                this.ͺ = "forum|user_message|,im_0";
                this.ॱˎ = iMessageHomeProtocol.getKindId();
            }
            return true;
        }
        Toast.makeText(this, j.ꓸ, 0).show();
        return false;
    }

    private void ॱˊ() {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        View findViewById = findViewById(o.bvj.b.ꞌ);
        azb.ˏ(findViewById);
        ˋ(findViewById);
        ((TextView) findViewById.findViewById(o.bvj.b.ˈॱ)).setText(this.ॱˋ);
        if (new bvy().ˏ(this.ॱˎ, this.ˋॱ)) {
            ImageView imageView = (ImageView) findViewById.findViewById(o.bvj.b.ॱʼ);
            imageView.setVisibility(0);
            imageView.setImageResource(c.ᐝॱ);
            findViewById.findViewById(o.bvj.b.ـ).setOnClickListener(new evx(this) {
                final /* synthetic */ MessageHomeActivity ˊ;

                {
                    this.ˊ = r1;
                }

                public void ˋ(View view) {
                    this.ˊ.ᐝॱ();
                }
            });
        }
    }

    private void ᐝॱ() {
        if (UserSession.getInstance().isLoginSuccessful()) {
            fjb ˎ = fho.ˏ().ˋ("Message").ˎ("buoy_msg_setting_activity");
            ((IBuoyMsgSwitchSettingActivityProtocol) ˎ.ˊ()).setDomainId(bqv.ˊ.ˎ());
            fiu.ˊ().ॱ((Context) this, ˎ, new fjc(this) {
                final /* synthetic */ MessageHomeActivity ˎ;

                {
                    this.ˎ = r1;
                }

                public void ˎ(int i, Object obj) {
                    if (i == -1 && (obj instanceof IBuoyMsgSwitchSettingActivityResult)) {
                        IBuoyMsgSwitchSettingActivityResult iBuoyMsgSwitchSettingActivityResult = (IBuoyMsgSwitchSettingActivityResult) obj;
                        if (this.ˎ.ʻॱ instanceof MessageHomeFragment) {
                            ((MessageHomeFragment) this.ˎ.ʻॱ).ˋ(iBuoyMsgSwitchSettingActivityResult.getMsgSetting());
                        }
                    }
                }
            });
            return;
        }
        bqx.ˋ("MessageHomeActivity", "openBuoyMsgSettingActivity unlogin error");
    }

    private void ˋ(View view) {
        view.findViewById(o.bvj.b.ˏˏ).setOnClickListener(new evx(this) {
            final /* synthetic */ MessageHomeActivity ˋ;

            {
                this.ˋ = r1;
            }

            public void ˋ(View view) {
                this.ˋ.onBackPressed();
            }
        });
    }

    private void ʼॱ() {
        ((cbh) fho.ˏ().ˋ("User").ॱ(cbh.class)).ˎ(this, 1).ˋ(fjt.ˋ(), new fjq<Boolean>(this) {
            final /* synthetic */ MessageHomeActivity ˊ;

            {
                this.ˊ = r1;
            }

            public void onComplete(fjo<Boolean> o_fjo_java_lang_Boolean) {
                if (o_fjo_java_lang_Boolean.ˊ() && ((Boolean) o_fjo_java_lang_Boolean.ॱ()).booleanValue()) {
                    this.ˊ.ᐝ();
                    return;
                }
                bqx.ˏ("MessageHomeActivity", "-------check user fail");
                this.ˊ.finish();
            }
        });
    }

    protected void ᐝ() {
        eoj.ˋ().ˎ("MessageHomeActivity", new b(this));
        fjb ˎ = fho.ˏ().ˋ("Message").ˎ("message.home");
        IMessageHomeFrgProtocol iMessageHomeFrgProtocol = (IMessageHomeFrgProtocol) ˎ.ˊ();
        iMessageHomeFrgProtocol.setUri(this.ͺ);
        iMessageHomeFrgProtocol.setSourceType(this.ˋॱ);
        iMessageHomeFrgProtocol.setDomainId(bsv.ॱ(this.ᐝॱ).ˎ());
        iMessageHomeFrgProtocol.setKindId(this.ॱˎ);
        fjm ˏ = fjm.ˏ(fiu.ˊ().ˋ(this, ˎ));
        FragmentTransaction ˊ = ˏॱ().ˊ();
        this.ʻॱ = ˏ.ˏ();
        ˊ.ˏ(o.bvj.b.ˊᐝ, this.ʻॱ, "forumHome");
        ˊ.ˋ();
    }

    public void onDestroy() {
        ((eke) cdb.ॱ(eke.class)).ˋ();
        eoj.ˋ().ˊ("MessageHomeActivity");
        super.onDestroy();
    }
}
